﻿// Add By HanDongji @2018/10/9

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class HotKeys : MonoBehaviour 
{
    #region Public Methods
    [MenuItem("Tools/HotKey/Clear Console &c")]
    public static void ClearConsole()
    {
        Type entries = System.Type.GetType("UnityEditorInternal.LogEntries,UnityEditor.dll");
        var clearFunc = entries.GetMethod("Clear", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
        if (clearFunc != null)
        {
            //执行清除
            clearFunc.Invoke(null, null);
        }
        else
        {
            Debug.LogWarning("Can't find clearFunc");
        }
    }

    [MenuItem("Tools/HotKey/Align View to MainCamera &#f")] 
    public static void AlignViewToMainCamera () 
    {
        if (SceneView.lastActiveSceneView != null && Camera.main != null)
        {
            SceneView.lastActiveSceneView.orthographic = true;
            SceneView.lastActiveSceneView.AlignViewToObject(Camera.main.transform);
        }
    }
	#endregion
}
